package com.dts.evaluate.ui.activity;

import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.dts.evaluate.R;
import com.dts.evaluate.bean.Worker;
import com.dts.evaluate.common.Constants;
import com.dts.evaluate.ui.view.TitleView;
import com.dts.evaluate.utils.LogUtil;
import com.dts.evaluate.utils.StringUtils;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 岗位职责
 */
public class ResponsibiliesActivity extends BaseActivity {

    @Bind(R.id.content_textview)
    TextView contentTextview;
    @Bind(R.id.title_view)
    TitleView titleView;

    public static final String NO_RESPONSIBILITIES = "<font>暂无相关职责信息</font>";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_responsibilies);
        ButterKnife.bind(this);

        titleView.setOnBackClickListener(new TitleView.OnBackClikListener() {
            @Override
            public void onTitleViewClik(View v) {
                finish();
            }
        });

        Worker worker = (Worker) getIntent().getSerializableExtra(Constants.WORKER);
        LogUtil.v("worker:"+worker);
        initView(worker);
    }

    /**
     * 初始化控件
     * @param worker
     */
    private void initView(Worker worker){
        if(worker == null){
            return;
        }
        String responsiblities = worker.getGscOrganFunction();
        LogUtil.v("responsib:"+responsiblities);
        if(StringUtils.isBlank(responsiblities)){
            responsiblities = NO_RESPONSIBILITIES;
        }

        contentTextview.setText(Html.fromHtml(responsiblities));
    }
}
